package cn.tedu.controller;

import cn.tedu.entity.User;
import cn.tedu.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

/**
 * Author：程Sir
 * Name： SpringTest01
 * Content:\
 *   查询所有的用户信息！
 */
//@WebServlet("/selectAll.do")
@Component
public class UserServlet {

    // 通过依赖注入的方式引入UsreService对象
    @Resource
    private UserService userService;

    // 自定义的service方法
    public  void service() throws ServletException, IOException {
        try {
            List<User> list = userService.selectAll();
            System.out.println(list);
            System.out.println("程序执行完毕！");

        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
}
